package com.lagou;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class SortMapper extends Mapper<LongWritable, Text, IntWritable, NullWritable> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        //从输入读取数字，转化为IntWritable
        int num = Integer.parseInt(value.toString());
        IntWritable intWritable = new IntWritable();
        intWritable.set(num);

        //写入context
        context.write(intWritable, NullWritable.get());
    }
}
